package org.sag.mallbf.type;

public enum ContentType {
    /*
     * Vertex Data
     */
    V(1, "v ", "Vertex"), //Polygon (3) or Free-Form (4) (default is 1.0)
    VP(2, "vp ", "Parameterized Vertex"), //Free-Form
    VN(3, "vn ", "Normal Vertex"), //Free-Form
    VT(4, "vt ", "Texture Vertex"), //Free-Form
    CSTYPE(6, "cstype ", "Curve/Surface Type"),
    DEG(7, "deg ", "Degree"),
    BMATU(8, "bmat u ", ""),
    BMATV(9, "bmat v ", ""),
    STEP(10, "step ", ""),
    /*
     * Elements
     */
    P(11, "p ", "Point"),
    L(12, "l ", "Line"),
    F(13, "f ", "Face"),
    CURV(14, "curv ", "Curve"),
    CURV2(15, "curv2 ", "Curve2"),
    SURF(16, "surf ", "Surface"),
    /*
     * Free-form curve/surface body statements
     */
    /*
     * Connectivity between free-form surfaces
     */
    /*
     * Grouping
     */
    OBJECT(1234, "o ", "Object"),
    GROUP(1235, "g ", "Group"),
    SMOOTH(1236, "s ", "Smoothing Groups Following"),
    MGGROUP(1237, "mg ", "Groups Following Will Be Merged"),
    /*
     * Display And Render
     */
    ;

    private int value;
    private String abbr;
    private String name;

    ContentType(int v, String a, String n) {
        this.value = v;
        this.abbr = a;
        this.name = n;
    }

    public static ContentType get(int v) {
        for (ContentType t : values()) {
            if (t.getValue() == v) {
                return t;
            }
        }
        return null;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAbbr() {
        return abbr;
    }

    public void setAbbr(String abbr) {
        this.abbr = abbr;
    }

    public static ContentType of(String origin) {
        for (ContentType t : values()) {
            if (origin.startsWith(t.getAbbr())) {
                return t;
            }
        }
        return null;
    }
}
